package com.xingkeduo.business.transformation.json;

import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;

import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.xingkeduo.pojo.enums.HairStyleEnums;
import com.xingkeduo.pojo.table.ConsumerStyleTO;
import com.xingkeduo.util.pojo.base.BaseJson;

/**
 * @Description:	
 * @Author:pantong
 * @Date 2019/2/19 10:32
 **/
@Component
public class ConsumerStyleJTO extends BaseJson {

    

    /**
     * 用户风格定位信息
     *
     * @param table:
     * @return : com.fasterxml.jackson.databind.node.ObjectNode
     * @author : gaozifeng
     */
    public static ObjectNode toJson(List<ConsumerStyleTO> consumerStylsList) throws Throwable {
        ObjectNode root = MAPPER.createObjectNode();
        
        ArrayNode consumerStyleList = MAPPER.createArrayNode();
        if(consumerStylsList!=null && consumerStylsList.size()>0) {
        	for (int i = 0; i < consumerStylsList.size(); i++) {
        		if(StringUtils.isNotEmpty(consumerStylsList.get(i).getStyleId())) {
        			consumerStyleList.add(consumerStylsList.get(i).getStyleId());
        		}
			}
        }
        root.put("choose_style_list", consumerStyleList);
        
        ArrayNode tagStyleList = MAPPER.createArrayNode();
        
        HairStyleEnums[] hairStyleS = HairStyleEnums.values();
        if(hairStyleS!=null && hairStyleS.length>0) {
        	for (int i = 0; i < hairStyleS.length; i++) {
           	    ObjectNode jNode = MAPPER.createObjectNode() ;
           	    jNode.put("f_id", hairStyleS[i].getId());
                jNode.put("f_name", hairStyleS[i].getName());
                tagStyleList.add(jNode);
        	}
        }
        root.put("tag_feel_style_list", tagStyleList);
        
        return root;
    }

     
}
